package com.chnbst.bstyun.controller.user;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.chnbst.bstyun.eos.Eos;
import com.chnbst.bstyun.model.pojo.temp.CallBill;

/**
 * 控制器注解 请求映射注解 controller 代表类是控制器 restcontroller 代表类是控制器， 所有的方法 都是ajax方法
 */
@Controller
@RequestMapping("/call")
public class CallController {
	

	/**
	 * 注入 业务逻辑层
	 */
	@Autowired
	private Eos eos;

	/**
	 * @return 话费查询页面
	 * @throws Exception  /call/cost
	 */
	@RequestMapping(value = "/cost", method = RequestMethod.GET)
	public ModelAndView cost(HttpServletRequest request) throws Exception {
		
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("users/call/callCenter");
	
		return modelAndView;
	}
	
	/**
	 * @return 欠费记录
	 * @throws Exception  /call/oweBill
	 */
	@RequestMapping(value = "/oweBill", method = RequestMethod.GET)
	public ModelAndView oweBill(HttpServletRequest request) throws Exception {
		
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("users/call/oweBill");
	
		return modelAndView;
	}
	
	/**
	 * @return 缴费记录
	 * @throws Exception  /call/paymentBill   
	 */
	@RequestMapping(value = "/paymentBill", method = RequestMethod.GET)
	public ModelAndView paymentBill(HttpServletRequest request) throws Exception {
		
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("users/call/paymentBill");
	
		return modelAndView;
	}
	
	/**
	 * @return 历史账单
	 * @throws Exception  /call/historyBill   
	 */
	@RequestMapping(value = "/historyBill", method = RequestMethod.GET)
	public ModelAndView historyBill(HttpServletRequest request) throws Exception {
		
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("users/call/historyBill");
	
		return modelAndView;
	}
	
	/**
	 * @return 通话详单
	 * @throws Exception  /call/callDetail   
	 */
	@RequestMapping(value = "/callDetail", method = RequestMethod.GET)
	public ModelAndView callDetail(HttpServletRequest request) throws Exception {
		
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("users/call/callDetail");
	
		return modelAndView;
	}
	
	/**
	 * 分页查询 通话详单
	 * @return 通话详单页面
	 * @throws Exception
	 */
	@RequestMapping(value="/callBillList",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> callBillList()throws Exception{
		Map<String, Object> map = eos.getBills("1385456452",10,1,"","");
		return map;
	}
	
	/**
	 * @return 话费充值
	 * @throws Exception  /call/callRecharge   
	 */
	@RequestMapping(value = "/callRecharge", method = RequestMethod.GET)
	public ModelAndView callRecharge(HttpServletRequest request) throws Exception {
		
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("users/call/callRecharge");
	
		return modelAndView;
	}
}
